//package com.gan.simple_init.quartz.config;
//
//
//import com.gan.simple_init.quartz.factory.JobFactory;
//import org.quartz.Scheduler;
//import org.springframework.beans.factory.config.PropertiesFactoryBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
//
//import javax.annotation.Resource;
//import java.io.IOException;
//import java.util.Properties;
//
//@Configuration
//public class QuartzConfigration {
//
//    @Resource
//    private JobFactory jobFactory;
//
//    @Bean
//    public SchedulerFactoryBean schedulerFactoryBean() {
//        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
//        try {
//            schedulerFactoryBean.setOverwriteExistingJobs(true);
//            schedulerFactoryBean.setQuartzProperties(quartzProperties());
//            schedulerFactoryBean.setJobFactory(jobFactory);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return schedulerFactoryBean;
//    }
//
//    /**
//     * 指定quartz.properties，可在配置文件中配置相关属性
//     * @return
//     * @throws IOException
//     * todo 修改quartz配置
//     */
//    @Bean
//    public Properties quartzProperties() throws IOException {
//        PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
//        propertiesFactoryBean.setLocation(new ClassPathResource("/config/quartz.properties"));
//        propertiesFactoryBean.afterPropertiesSet();
//        return propertiesFactoryBean.getObject();
//    }
//
//    /**
//     * 创建schedule
//     * @return
//     */
//    @Bean(name = "scheduler")
//    public Scheduler scheduler() {
//        return schedulerFactoryBean().getScheduler();
//    }
//}
//
